﻿import com.gamemeal.mvc.IModelField;
import com.gamemeal.mvc.datatype.MFObject;
/**
 * @author Colin
 */
class com.gamemeal.mvc.datatype.MFArray extends MFObject implements IModelField{
	static var CASEINSENSITIVE:Number;
	static var DESCENDING:Number;
	static var NUMERIC:Number;
	static var RETURNINDEXEDARRAY:Number;
	static var UNIQUESORT:Number;
	
	public var value:Array;
	/**
	 * Class constructor
	 * @param value Array of data
	 * @param storeProcedure the function call when this object's value change. 
	 */
	public function MFArray(value:Array,storeProcedure:Function){
		super(value,storeProcedure);
	};

	public function concat(value:Object):Array{
		return this.value.concat(value);
	};
	public function join(delimiter:String):String{
		return this.value.join(delimiter);
	};

	public function pop():Object{
		return this.value.pop();
	};

	public function push(value):Number{
		return this.value.push(value);
	};
	public function reverse():Void{
		this.value.reverse();
	};
	public function shift():Object{
		return this.value.shift();
	};

	public function slice(startIndex:Number, endIndex:Number):Array{
		return this.value.slice(startIndex,endIndex);
	};

	public function sort(compareFunction:Object, options: Number):Array{
		return this.value.sort(compareFunction,options);
	} // 'compare' might be omitted so untyped. 'options' is optional.

	public function sortOn(fieldName:Object, options: Object):Array{
		return this.value.sortOn(fieldName,options);
	}; // 'fieldName' is a String, or an Array of String. 'options' is optional.

	public function splice(startIndex:Number, deleteCount:Number, value:Object):Array{
		return this.value.splice(startIndex,deleteCount,value);
	};

	public function toString():String{
		return this.value.toString();
	};
	public function unshift(value:Object):Number{
		return this.value.unshift(value);
	};
	
	public function get length():Number{
		return this.value.length;
	}
}